package com.yt.dor.service;

import com.yt.dor.models.vo.ViolationRecordVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.dor.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.dor.mapper.ViolationRecordMapper;
import com.yt.dor.models.service.IViolationRecordService;
import com.yt.dor.models.bo.ViolationRecordSaveBO;
import com.yt.dor.models.dto.ViolationRecordDTO;

import java.util.Collections;
import java.util.List;

/**
 * 违规表详情控制器
 *
 * @author thekai
 * @Date 2025-10-28 16:38:28
 */
@DubboService
public class ViolationRecordServiceImpl extends ServiceImpl<ViolationRecordMapper, ViolationRecordDTO> implements IViolationRecordService {

    @Resource
    private YmlConfig ymlConfig;
    @Resource
    private ViolationRecordMapper violationRecordMapper;
    @Override
    public boolean add(ViolationRecordSaveBO saveBO) {
        ViolationRecordDTO dto = new ViolationRecordDTO();
        BeanUtils.copyProperties(saveBO, dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);

        return this.insert(dto);
    }

    @Override
    public List<ViolationRecordVO> query() {
        List<ViolationRecordVO> violationRecordVOS=violationRecordMapper.query();
        return violationRecordVOS;
    }

    @Override
    public List<ViolationRecordVO> statistics(Integer semester, Long roomId) {
        return violationRecordMapper.statistics(semester, roomId);
    }
}